package grape.workflow.rest.client.impl.process;

import grape.workflow.rest.client.process.ProcessClient;
import org.flowable.rest.service.api.runtime.process.ProcessInstanceCollectionResource;
import org.flowable.rest.service.api.runtime.process.ProcessInstanceCreateRequest;
import org.flowable.rest.service.api.runtime.process.ProcessInstanceResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by yangwei
 * Created at 2020/6/15 16:42
 */
@Component
public class ProcessClientImpl implements ProcessClient {


    @Autowired
    private HttpServletRequest request;

    @Autowired
    private HttpServletResponse response;


    /**
     * 由于该原始bean不是root上下文中，不能自动注入，这里手动注入一个
     */
    @Qualifier("myProcessInstanceCollectionResource")
    @Autowired
    private ProcessInstanceCollectionResource processInstanceCollectionResource;

    @Override
    public ProcessInstanceResponse createProcessInstance(ProcessInstanceCreateRequest createRequest) {

        return processInstanceCollectionResource.createProcessInstance(createRequest, request, response);
    }
}
